import 'package:Smart/pages/productor006/project/pages/gs_callout_page.dart';
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:Smart/utils/routers/page_jump_service.dart';
//屏幕适配
import 'package:Smart/utils/screen_unit/gs_screen_util.dart';
import '../res/colors_res.dart';

import '../pages/gs_callout_dialog.dart';

/// 平台权限检测并申请设置工具类
///
class GSPermissionUtil {
  //检测并申请电话权限
  static Future<bool> requestPhonePermission({BuildContext context}) async {
    //获取当前的权限
    var status = await Permission.phone.status;
    if (status == PermissionStatus.granted) {
      return true;
    } else {
      status = await Permission.phone.request();
      if (status == PermissionStatus.granted) {
        return true;
      } else {
        if (context != null) {
          showDialog(
              context: context,
              builder: (_) => GSBlueToothDialog(
                    context,
                    '您需要打开电话权限，请到设置中开启',
                    '取消',
                    '去设置',
                  ));
        }
        return false;
      }
    }
  }
}
